#define _CRT_SECURE_NO_WARNINGS	

#include <stdio.h>
#include<stdbool.h>

bool Find(int x)
{
    if (x % 7 == 0)
        return true;
    int find = 0;
    while (x)
    {
        int tmp = x % 10;
        if (tmp == 7)
            return true;
        x /= 10;
    }
    return false;
}

int main()
{
    int n;
    scanf("%d", &n);
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (Find(i))
            count++;
    }
    printf("%d\n", count);
}